package com.ccepc.algmanage.utils;

import com.ccepc.common.security.service.PigxUser;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

public class AuthInfoUtils {

    /**
     * 获取登录用户信息
     * @return 用户
     */
    private static PigxUser getCurrentUser() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        return (PigxUser) authentication.getPrincipal();
    }

    public static Integer getTenantId() {
        return getCurrentUser().getTenantId();
    }

    public static Long getUserId() {
        return getCurrentUser().getId();
    }

    public static String getFullName() {
        return getCurrentUser().getFullName();
    }

}
